import routeCheck from 'super-project/React/route-check'
import Root from '@ui/app'



const router = __CLIENT__ ?

    {
        // path: __SPA__ ? '/' : '',
        component: Root,
        name: 'app-root',

        indexRoute: {
            getComponent: (nextState, cb) => {
                require.ensure([], (require) => {
                    if (routeCheck(nextState)) cb(null, require('@ui/pages/home').default)
                }, 'home')
            }
        },

        childRoutes: [
            {
                path: 'order',
                name: 'order',
                getComponent: (nextState, cb) => {
                    require.ensure([], (require) => {
                        if (routeCheck(nextState)) cb(null, require('@ui/pages/order').default)
                    }, 'order')
                }
            },
            {
                path: 'deliver',
                name: 'deliver',
                getComponent: (nextState, cb) => {
                    require.ensure([], (require) => {
                        if (routeCheck(nextState)) cb(null, require('@ui/pages/deliver').default)
                    }, 'deliver')
                }
            },
        ]
    }

    :

    {
    // path: __SPA__ ? '/' : '',
        component: Root,
        name: 'app-root',
        childRoutes: [{
            path: '*',
            name: 'order',
            getComponent: (nextState, cb) => {
                require.ensure([], (require) => {
                    if (routeCheck(nextState)) cb(null, require('@ui/pages/home').default)
                }, 'home')
            }
        }]
    }
export default router